import Home from "@/pages/Home/index.vue";
import Login from "@/pages/Login/index.vue";
import Register from "@/pages/Register/index.vue";
import Search from "@/pages/Search/index.vue";
// import Detail from "@/pages/Detail/index.vue";
import AddCartSuccess from "@/pages/AddCartSuccess";
import ShopCart from "@/pages/ShopCart";
import Trade from "@/pages/Trade";
import Pay from "@/pages/Pay";
import PaySuccess from "@/pages/PaySuccess";
import Center from "@/pages/Center";

export default [
  {
    path: "/home",
    name: "home",
    component: Home,
  },
  {
    name: "login",
    path: "/login",
    component: Login,
    meta: {
      isShowFooter: true,
    },
  },
  {
    name: "register",
    path: "/register",
    component: Register,
    meta: {
      isShowFooter: true,
    },
  },
  {
    name: "detail",
    path: "/detail/:skuId",
    component: () => import("@/pages/Detail"),
  },
  {
    name: "search",
    path: "/search",
    component: Search,
  },
  {
    name: "addsuccess",
    path: "/add_success",
    component: AddCartSuccess,
    beforeEnter: (to, from, next) => {
      from.path.includes("/detail") ? next() : next(from.path);
    },
  },
  {
    name: "shopcart",
    path: "/shopcart",
    component: ShopCart,
  },
  {
    name: "trade",
    path: "/trade",
    component: Trade,
  },
  {
    name: "pay",
    path: "/pay",
    component: Pay,
    beforeEnter: (to, from, next) => {
      from.path === "/trade" ? next() : next(from.path);
    },
  },
  {
    name: "paysuccess",
    path: "/paysuccess",
    component: PaySuccess,
    beforeEnter: (to, from, next) => {
      from.path === "/pay" ? next() : next(from.path);
    },
  },
  {
    name: "center",
    path: "/center",
    component: Center,
  },
  {
    path: "/",
    redirect: "/home",
  },
];
